#!/bin/bash

mkdir mqtt2bc
cd mqtt2bc
sudo apt-get install libmysqlclient-dev -y
sudo pip3 install --upgrade setuptools
sudo pip3 install mysql-connector-python
sudo pip3 install paho-mqtt
sudo dos2unix /root/LAMP2021/mqtt2sql-20210706V2.py
sudo dos2unix /root/LAMP2021/mqtt2sql-20210706.service
sudo cp /root/LAMP2021/mqtt2sql-20210706V2.py /root/mqtt2bc/mqtt2sql.py
sudo cp /root/LAMP2021/mqtt2sql-20210706.service /lib/systemd/system/mqtt2sql.service
sudo cp /root/LAMP2021/sql2bc-20210706.php /var/www/html/phpweb3/esbc_public/sql2bc.php
systemctl enable mqtt2sql.service
systemctl start mqtt2sql.service
# Get its PID
PID=$!
# Wait for 2 seconds
sleep 30
# Kill it
kill $PID
